import {
  BrowserRouter as Router,
  Route,
  Switch,
  Link,
  NavLink,
  useHistory,
} from 'react-router-dom';
// import { HashRouter as Router, Route, Link } from 'react-router-dom';

import './App.css';

const Login = () => {
  const history = useHistory();

  const onLogin = () => {
    // ...
    history.replace('/home');
  };
  return <button onClick={onLogin}>登录</button>;
};

const App = () => {
  // react-router-dom 对浏览器地址栏封装的 API

  return (
    <Router>
      <Route exact path={'/'} component={Login} />
      <Route path={'/home'} render={() => <div>Home</div>} />
    </Router>
  );
};

export default App;
